/****************************************************************************
 * Chariott - Continuous Integration Testing Tool
 * Zaid Mohsin
 * The University of York
 * 2012/2013
 * MSc in Information Technology
 * All rights reserved.
 ****************************************************************************/
package chariott.partition;

import java.util.ArrayList;

import org.apache.commons.collections.MultiHashMap;
import org.apache.commons.collections.MultiMap;

import chariott.testing.RunItem;

/**
 * an implementation of AlgorithmOrder that orders the run items by fair round
 * robin algorithm.
 * 
 * @author Zaid
 * 
 */
public class RoundRobinOrder extends AlgorithmOrder {

	public RoundRobinOrder(int numOfNodes, ArrayList<RunItem> itemsToRun) {
		super(numOfNodes, itemsToRun);

	}

	public MultiMap generateRuns() {

		MultiMap sortingMap = new MultiHashMap();

		for (int i = 0; i < itemsToRun.size(); i++) {
			sortingMap.put(i % numOfNodes, itemsToRun.get(i));
		}

		return sortingMap;
	}

}
